/**
 * Created by 小敏哥 on 2018/1/18.
 */
//获取应用实例
var app = getApp();
var data = {};
Page({
    data: {},
    onShow() {
        data = {};
    },
    save() {
        if (!data.mailboxNum) {
            app.errorToast('请输入正确的邮筒号');
            return;
        }
        let dataObj = {
            mailboxNum: data.mailboxNum,
            remark: data.remark ? data.remark : '',
        };
        //区分收件人地址和寄件人地址
        if (app.getStorageSync('addressType') != 'send') {
            dataObj.collectFlag = 1;
        }
        let opt = {
            url: app.globalData.host + "/wx/ad/addMailboxNum.ajax",
            data: dataObj,
            sucFn: (result) => {
                if (result.code == 1000) {
                    wx.navigateBack();
                }
                else {
                    wx.showToast({
                        title: result.msg,
                        icon: 'none',
                        duration: 2000
                    });
                }
            }
        };
        app.ajax(opt);
    },

    cancel() {
        wx.navigateBack();
    },
    mailboxChange(e) {
        data.mailboxNum = e.detail.value
    },
    remarkChange(e) {
        data.remark = e.detail.value
    }
});